﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using RedGlove.Lib;

namespace RGP.BLL
{
    public class Weather
    {
        /// <summary>
        /// 弹出JavaScript小窗口
        /// </summary>
        /// <param name="js">窗口信息</param>
        public static void GetWeather(string cityname)
        {
            #region 网站获取得的天气Json字符串详解

            //string jsonStr = "\"";
//详细解析格式如下：
//以json格式提供，格式如下 
//{"weatherinfo":{
////基本信息;
//"city":"北京","city_en":"beijing",
//"date_y":"2013年1月17日","date":"辛卯年","week":"星期三","fchh":"18","cityid":"101010100",
////摄氏温度
//"temp1":"24℃~33℃","temp2":"24℃~32℃","temp3":"25℃~31℃","temp4":"23℃~30℃","temp5":"22℃~30℃","temp6":"21℃~32℃",
////华氏温度;
//"tempF1":"75.2℉~91.4℉","tempF2":"75.2℉~89.6℉","tempF3":"77℉~87.8℉","tempF4":"73.4℉~86℉","tempF5":"71.6℉~86℉","tempF6":"69.8℉~89.6℉",
////天气描述;
//"weather1":"多云","weather2":"晴转多云","weather3":"阴","weather4":"晴转阵雨","weather5":"阵雨","weather6":"多云",
////天气描述图片序号
//"img1":"1","img2":"99","img3":"0","img4":"1","img5":"2","img6":"99","img7":"0","img8":"3","img9":"3","img10":"99","img11":"1","img12":"99",
//"img_single":"1",
////图片名称;
//"img_title1":"多云","img_title2":"多云","img_title3":"晴","img_title4":"多云","img_title5":"阴","img_title6":"阴","img_title7":"晴","img_title8":"阵雨","img_title9":"阵雨","img_title10":"阵雨","img_title11":"多云","img_title12":"多云","img_title_single":"多云",
////风速描述
//"wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风",
////???
//"fx1":"微风","fx2":"微风","fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",
////今天穿衣指数;
//"index":"炎热","index_d":"天气炎热，建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。",
////48小时穿衣指数
//"index48":"炎热","index48_d":"天气炎热，建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。"
////紫外线及48小时紫外线
//,"index_uv":"中等","index48_uv":"弱",
////洗车
//"index_xc":"适宜",
////旅游
//"index_tr":"较适宜",
////舒适指数
//"index_co":"较不舒适",
////
//"st1":"33","st2":"24","st3":"32","st4":"25","st5":"32","st6":"24",
////晨练
//"index_cl":"适宜",
////晾晒
//"index_ls":"适宜",
////过敏
//"index_ag":"极易发"}}
//字段言简意赅，城市名，英文名，日期，农历日期，星期，预报时间，城市代码，6个预报温度（华氏温度，摄氏温度），6个预报天气和风力，剩下的就是一些气象指数。
            #endregion

            string jsonStr = "{\"weatherinfo\":{\"city\":\"北京\",\"city_en\":\"beijing\",\"date_y\":\"2013年2月27日\",\"date\":\"\",\"week\":\"星期三\",\"fchh\":\"18\",\"cityid\":\"101010100\",\"temp1\":\"2℃~14℃\",\"temp2\":\"-3℃~7℃\",\"temp3\":\"-5℃~8℃\",\"temp4\":\"-3℃~14℃\",\"temp5\":\"0℃~15℃\",\"temp6\":\"2℃~15℃\",\"tempF1\":\"35.6℉~57.2℉\",\"tempF2\":\"26.6℉~44.6℉\",\"tempF3\":\"23℉~46.4℉\",\"tempF4\":\"26.6℉~57.2℉\",\"tempF5\":\"32℉~59℉\",\"tempF6\":\"35.6℉~59℉\",\"weather1\":\"阴转晴\",\"weather2\":\"晴\",\"weather3\":\"晴\",\"weather4\":\"多云\",\"weather5\":\"多云转晴\",\"weather6\":\"多云\",\"img1\":\"2\",\"img2\":\"0\",\"img3\":\"0\",\"img4\":\"99\",\"img5\":\"0\",\"img6\":\"99\",\"img7\":\"1\",\"img8\":\"99\",\"img9\":\"1\",\"img10\":\"0\",\"img11\":\"1\",\"img12\":\"99\",\"img_single\":\"0\",\"img_title1\":\"阴\",\"img_title2\":\"晴\",\"img_title3\":\"晴\",\"img_title4\":\"晴\",\"img_title5\":\"晴\",\"img_title6\":\"晴\",\"img_title7\":\"多云\",\"img_title8\":\"多云\",\"img_title9\":\"多云\",\"img_title10\":\"晴\",\"img_title11\":\"多云\",\"img_title12\":\"多云\",\"img_title_single\":\"晴\",\"wind1\":\"微风转北风6-7级\",\"wind2\":\"北风5-6级转微风\",\"wind3\":\"微风\",\"wind4\":\"微风\",\"wind5\":\"微风\",\"wind6\":\"微风\",\"fx1\":\"微风\",\"fx2\":\"北风\",\"fl1\":\"小于3级转6-7级\",\"fl2\":\"5-6级转小于3级\",\"fl3\":\"小于3级\",\"fl4\":\"小于3级\",\"fl5\":\"小于3级\",\"fl6\":\"小于3级\",\"index\":\"冷\",\"index_d\":\"天气冷，建议着棉服、羽绒服、皮夹克加羊毛衫等冬季服装。年老体弱者宜着厚棉衣、冬大衣或厚羽绒服。\",\"index48\":\"冷\",\"index48_d\":\"天气冷，建议着棉服、羽绒服、皮夹克加羊毛衫等冬季服装。年老体弱者宜着厚棉衣、冬大衣或厚羽绒服。\",\"index_uv\":\"中等\",\"index48_uv\":\"中等\",\"index_xc\":\"较适宜\",\"index_tr\":\"一般\",\"index_co\":\"较舒适\",\"st1\":\"12\",\"st2\":\"1\",\"st3\":\"5\",\"st4\":\"-6\",\"st5\":\"7\",\"st6\":\"-2\",\"index_cl\":\"不宜\",\"index_ls\":\"不太适宜\",\"index_ag\":\"极不易发\"}}";
            //通过字符串构建Json对象
            JsonObject newObj = new JsonObject(jsonStr);

            string city = newObj["weatherinfo"]["city"].Value; //城市名称
            string city_en = newObj["weatherinfo"]["city_en"].Value; //城市名称英语

        }
    }
}